﻿Imports System.Reflection
Imports DotNetNuke

Namespace DotNetNuke.Modules.Help
    Public Class ViewHelpCategoryPresenter

#Region "Private Memebers"
        Private View As IViewHelpTutorial
        Private Controller As IHelpTutorialController
#End Region


        Public Sub New(ByVal _View As IViewHelpCategory, ByVal _Controller As IHelpCategoryController)
            View = _View
            Controller = _Controller
        End Sub

        Public Sub OnLoaded(ByVal LoadForm As Boolean)
            Try
                'If LoadForm = False Then
                '    Dim colHelpTutorials As List(Of HelpTutorialInfo)

                '    ' get the content from the HelpTutorial table
                '    colHelpTutorials = Controller.GetHelpTutorials(View.ModuleId)

                '    If colHelpTutorials.Count = 0 Then
                '        ' add the content to the HelpTutorial table
                '        Dim objHelpTutorial As HelpTutorialInfo = New HelpTutorialInfo
                '        objHelpTutorial.ModuleId = View.ModuleId
                '        objHelpTutorial.Content = "View.Content"
                '        objHelpTutorial.CreatedByUser = View.ModuleId
                '        Controller.AddHelpTutorial(objHelpTutorial)
                '        ' get the content from the HelpTutorial table
                '        colHelpTutorials = Controller.GetHelpTutorials(View.ModuleId)
                '    End If
                '    ' bind the content to the repeater
                '    View.colHelpTutorials = colHelpTutorials
                'End If
            Catch exc As Exception
                View.Exception = exc
            End Try
        End Sub

        Public Function PrepareCurrentRow(ByVal _HelpTutorialInfo As HelpTutorialInfo) As String
            Dim strContent As String = ""

            ' add content to template
            'If CType(Settings("template"), String) <> "" Then
            'strContent = CType(Settings("template"), String)
            Dim objProperties As Dictionary(Of String, PropertyInfo) = Common.Utilities.CBO.GetProperties(Of HelpTutorialInfo)()
            Dim intProperty As Integer
            Dim objPropertyInfo As PropertyInfo
            For intProperty = 0 To objProperties.Count - 1
                objPropertyInfo = CType(objProperties(intProperty), PropertyInfo)
                strContent = strContent.Replace("[" & objPropertyInfo.Name.ToUpper & "]", DataBinder.Eval(_HelpTutorialInfo, objPropertyInfo.Name).ToString())
            Next intProperty
            'strContent = DataBinder.Eval(_HelpTutorialInfo, "Content")
            Return strContent
        End Function
    End Class
End Namespace


